#!/usr/bin/python
# -*- coding:utf-8 -*-
# 
class Persion(object):
	'This is a person class, contrain name and age'
	def __init__(self, name, age):
		super(Persion, self).__init__()
		self.age = age
		self.name = name

	def setName(self,name):
		self.name = name

	def getName(self):
		return self.name

	def greet(self):
		print "hello, world ! i am %s." % self.name

p = Persion('zhao','12')
print p.name, p.age
p.greet()
print Persion.__name__
print Persion.__doc__

class Class:
	def method(self):
		print 'i have a self'
def function():
	print 'i dont ...'
		

ins = Class()
ins.method()

ins.method = function
ins.method()

class Muffledcalculator():
	muffled = False
	def calc(self,expr):
		try:
			return eval(expr)
		except (ZeroDivisionError, TypeError):
			if self.muffled:
				print 'Division by zero is illegal'
			else:
				raise

calculator = Muffledcalculator()
calculator.muffled = True
print calculator.calc(10/2)

print calculator.calc('10/0')














